import 'dart:async';
import 'dart:io';

import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:sports_new/utils/routes.dart';
import 'package:sports_new/utils/toast_utils.dart';

class AttachDetector{
  static Timer? _timer;

  static List<String> warnRoutes = [
    Routes.myEditInfo,
    Routes.expertApply,
    Routes.accountVerify,
    Routes.login
  ];

  static void warn(){
    if(!warnRoutes.any((element) => Get.currentRoute.contains(element))) return;
    int i = 3;
    _timer = Timer.periodic(
      const Duration(seconds: 5),
      (timer) {
        i--;
        if(i == 0){
          ToastUtils.show("当前页面脱离焦点时间长，请注意信息安全");
          _timer?.cancel();
        }
      }
    );
  }

  static void cancelWarn(){
    _timer?.cancel();
  }

  static Future checkSimulator() async{
    // AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo;
    // if(!androidInfo.isPhysicalDevice || androidInfo.systemFeatures.every((element) => element.contains("android"))) {
    //   ToastUtils.show("本应用不支持在模拟器中运行");
    //   SystemNavigator.pop();
    // }else{
    //
    // }
  }

  Map<String,List<String>> brand = {"oppo":["oppo","op","oplus"]};
}